package com.mobilereports.service;

import java.util.LinkedList;
import java.util.List;

import com.mobilereports.model.Record;
import com.mobilereports.model.Report;
import com.mobilereports.model.ReportColumn;

public abstract class ReportsService {
	public abstract List<Report> getReports();
	public abstract List<ReportColumn> getReportColumns(Report report);
	public abstract List<Record> fetchData(Report report, List<ReportColumn> hierarchy, String path);
	
	public List<ReportColumn> getReportHierarchyColumns(Report report) {
		List<ReportColumn> columns = getReportColumns(report);
		List<ReportColumn> result = new LinkedList<ReportColumn>();
		
		for(ReportColumn col: columns) {
			if(col.isHierarchyCandidate()) {
				result.add(col);
			}
		}
		
		return result;
	}
	
	public List<ReportColumn> getReportMeasureColumns(Report report) {
		List<ReportColumn> columns = getReportColumns(report);
		List<ReportColumn> result = new LinkedList<ReportColumn>();
		
		for(ReportColumn col: columns) {
			if(col.isMeasure()) {
				result.add(col);
			}
		}
		
		return result;	
	}
}
